{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "将列表或元组解包赋值到多个变量的语法被称为序列解包（sequence unpacking）。更具描述性的变量名\n",
    "虽然这看起来像是一个元组，但其实是将每个元素分别赋给各个变量。这种写法在 Python 中很常见，用于从序列（列表、元组等）中提取元素并将它们分配给独立的变量。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "meats : List[str] = [\"bacon\", \"sausage\", \"ham\", \"chicken\"]\n",
    "# 序列解包 这样的写法更加健壮 \n",
    "( first :str, second :str, third :str, fourth :str) = meats # 不能在序列解包（也称为元组解包）的过程中直接对变量进行类型注解。\n",
    "print(first, second, third, fourth) # bacon sausage ham chicken"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "\n",
    "# 声明列表并进行类型注解\n",
    "meats: List[str] = [\"bacon\", \"sausage\", \"ham\", \"chicken\"]\n",
    "\n",
    "# 声明变量并进行类型注解\n",
    "first: str\n",
    "second: str\n",
    "third: str\n",
    "fourth: str\n",
    "\n",
    "# 序列解包\n",
    "first, second, third, fourth = meats\n",
    "\n",
    "# 打印变量\n",
    "print(first, second, third, fourth)  # bacon sausage ham chicken"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
